﻿using System;
using System.Collections.Generic;
namespace Program21
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入用户名:");
            var name = Console.ReadLine();
            Console.WriteLine("请输入密码:");
            var pwd = Console.ReadLine();

            var msg = "";

            var status = Login(name, pwd, out msg);
            Console.WriteLine("登录结果{0},提醒{1}", status, msg);
        }

        public static bool Login(string name, string pwd, out string statusMessage)
        {
            statusMessage = "登录失败!";

            if (string.IsNullOrEmpty(name))
            {
                statusMessage = "用户名不能为空，请重试。";
                return false;
            }

            if (string.IsNullOrEmpty(name))
            {
                statusMessage = "密码不能为空，请重试。";
                return false;
            }

            //检索是否存在此用户名
            var users = new List<string>();
            users.Add("叫我声靓仔");
            if (!users.Contains(name))
            {
                statusMessage = "此用户不存在，请重试。";
                return false;
            }

            //检索口令是否正确
            if (name == "叫我声靓仔" && pwd == "26548")
            {
                statusMessage = "登录成功，请尽情娱乐。";
                return true;
            }
            else
            {
                statusMessage = "登录失败，请重试。";
                return false;
            }
        }
    }
}
